#include "wrapper.h"
#include <memory.h>
#include "src_ok/global.h"
#include "core/measprog.h"
#include "core/ctrl.h"
#include "core/ctrlthread.h"

measure_s* getMeasDataPtr()
{
	return &meas_tmp;
}

total_s* getTotalDataPtr()
{
	return &total;
}

program_s* getTestProgPtr()
{
	return &prog;
}

program_s* getMeasProgPtr()
{
	MeasProg* pm = MeasProg::getInstance();
	program_s* p = pm->getProgPtr();

	return p;
}

void CopyProgramToMeasProg()
{
	program_s *p = getMeasProgPtr();
	memcpy(p, &prog, sizeof(program_s));
}

void emitMeasDataReady()
{
	Ctrl* pc = Ctrl::getInstance();
	CtrlThread* thread = pc->getCtrlThread();

	thread->emitMeasDataReadySignal();
}

// Implementations placed in file src_ok/main.c
//void initDevices();
//void releaseDevices();
//void meas_main(); 

bool getMeasStatus()
{
	Ctrl* pc = Ctrl::getInstance();
	CtrlThread* thread = pc->getCtrlThread();

	return thread->getMeasStatus();
}


int autoModeWait(int* key)
{
	Ctrl* pc = Ctrl::getInstance();
	CtrlThread* thread = pc->getCtrlThread();
	
    return thread->scanbuttons(key);	
}

int manualModeWait()
{
	Ctrl* pc = Ctrl::getInstance();
	CtrlThread* thread = pc->getCtrlThread();
	return thread->waitManual();
}
